em_impute Subroutine

public subroutine em_impute(x, xc, mu, sigma, maxiter, tol, niter)

Employs the expectation-maximization (EM) algorithm to compute the maximum-likelihood estimates of the mean vector and covariance matrix of a multivariate normal population from a data set containing missing values. The missing values are then replaced by their conditional expectations given the observed values and the converged parameter estimates.

The estimator assumes the data are missing at random (MAR).

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:,:) :: x

An N-by-M matrix containing N observations of M variables. Missing entries must be denoted by NaN's (see missing_value).

real(kind=real64), intent(out), dimension(:,:) :: xc

An N-by-M matrix where the completed data set will be written.

real(kind=real64), intent(out), optional, dimension(:) :: mu

An optional M-element array where the maximum-likelihood estimate of the mean vector will be written.

real(kind=real64), intent(out), optional, dimension(:,:) :: sigma

An optional M-by-M matrix where the maximum-likelihood estimate of the covariance matrix will be written.

integer(kind=int32), intent(in), optional :: maxiter

An optional input specifying the maximum number of iterations to allow. The default is 500.

real(kind=real64), intent(in), optional :: tol

An optional input specifying the convergence tolerance. The iteration terminates once the largest change in any parameter falls below this value. The default is 1.0e-8.

integer(kind=int32), intent(out), optional :: niter

An optional output containing the number of iterations performed.